package com.liuhouse1.web;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class MyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req , resp);
    }

    //我在这些servlet的时候是为了处理浏览器的请求 做一些前置的工作
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();
        //输出内容到浏览器
        out.println("在Servlet输出中文,默认编码为ISO-8859-1");
        System.out.println("拦截器拦截到了");
        out.flush();
        out.close();
    }
}
